<template>
	<view class="publish" v-if="isPublishPopup">
		<view class="publish_ceng" @click="closePublishPopup"></view>
		<!-- <view class="publish_button">
			<view class="publish_btn" @click="addCommunityButton(1)">发布广告</view>
			<view class="publish_btn" @click="addCommunityButton(4)">服务商入驻</view>
			<view class="publish_btn" @click="addCommunityButton(3)">发布需求</view>
			<view class="publish_btn" @click="addCommunityButton(2)" v-if="is_community_video_start == 1">发布视频</view>
			<view class="publish_btn" @click="addCommunityButton(5)">发布商品</view>
			<view class="publish_btn" @click="closePublishPopup()" style="color: #000;background-color: #f1ebeb; padding: 20rpx 0;">关闭</view>
		</view> -->
		<view class="select_checked" v-if="type == 1">
			<view class="selected_checket_title">发布</view>
			<view class="selected_checket_item">
				<view class="item" @click="addCommunityButton(1)">
					<view class="item-img">
						<image src="https://img.jukee.net/def/41814202309292007528183.jpg" />
					</view>
					<view class="item-tit">广告</view>
				</view>
				<view class="item" @click="addCommunityButton(3)">
					<view class="item-img">
						<image src="https://img.jukee.net/def/eaebf202309292007495318.jpg" />
					</view>
					<view class="item-tit">订单</view>
				</view>
				<view class="item" @click="addCommunityButton(2)" v-if="is_community_video_start == 1">
					<view class="item-img">
						<image src="https://img.jukee.net/def/831df202309292007512163.jpg" />
					</view>
					<view class="item-tit">视频</view>
				</view>
				<view class="item">
					<view class="item-img" @click="addCommunityButton(5)">
						<image src="https://img.jukee.net/def/399f7202309292007517596.png" />
					</view>
					<view class="item-tit">商品</view>
				</view>
			</view>
		</view>
		<view class="select_checked" v-else>
			<view class="selected_checket_title">发布</view>
			<view class="selected_checket_item">
				<view class="item" @click="addCommunityButton(1)">
					<view class="item-img">
						<image src="https://img.jukee.net/def/41814202309292007528183.jpg" />
					</view>
					<view class="item-tit">广告</view>
				</view>
				<view class="item" @click="addCommunityButton(3)">
					<view class="item-img">
						<image src="https://img.jukee.net/def/eaebf202309292007495318.jpg" />
					</view>
					<view class="item-tit">订单</view>
				</view>
				<view class="item" @click="addCommunityButton(2)" v-if="is_community_video_start == 1">
					<view class="item-img">
						<image src="https://img.jukee.net/def/831df202309292007512163.jpg" />
					</view>
					<view class="item-tit">视频</view>
				</view>
				<view class="item">
					<view class="item-img" @click="addCommunityButton(6)">
						<image src="https://img.jukee.net/def/24457202309292007472653.jpg" />
					</view>
					<view class="item-tit">人脉圈</view>
				</view>
			</view>
			<!-- <view class="selected_checket_item">
				<view class="item" @click="addCommunityButton(4)">
					<view class="item-img">
						<image src="https://img.jukee.net/def/46cf0202309292007502612.jpg" />
					</view>
					<view class="item-tit">服务商</view>
				</view>
				<view class="item">
					<view class="item-img" @click="addCommunityButton(5)">
						<image src="https://img.jukee.net/def/399f7202309292007517596.png" />
					</view>
					<view class="item-tit">供应商</view>
				</view>
			</view> -->
		</view>
		<!-- 升级VIP弹窗 -->
		<view class="user_vip_tips" v-if="user_vip_tips">
			<view class="user_vip_back"></view>
			<view class="user_vip_content">
				<view class="user_vip_close" @click="user_vip_tips = false">
					<image src="https://ly.jukee.net/uploads/default/20230803/8d5635ef7c1504bfadbd85f0a04270cc.png" />
				</view>
				<view class="user_vip_icon">
					<image src="https://img.jukee.net/def/3902e202311271626269626.png" />
				</view>
				<view class="user_vip_title font-size32-bold">成为VIP会员</view>
				<view class="user_vip_tit font-size36-bold" style="font-size: 46rpx;">无限添加客户微信<br/>查看所有客户联系方式</view>
				<view class="user_vip_messag">更多权益请在 “我的” 会员中心查看</view>
				<view class="user_vip_btn" @click="goUrl('/pages/annex/vip_paid/index')">确定</view>
			</view>
		</view>
	</view>
</template>

<script>
	import { userPerm, userHasReward } from '@/api/user.js';
	import { mapGetters } from "vuex";
	import { configMap } from '@/utils';
	export default {
		name: 'PublishPopup',
		data() {
			return {
				user_vip_tips: false,
			}
		},
		props: {
			isPublishPopup: {
				type: Boolean,
				default: false
			},
			type: {
				type: Number,
				default: 0
			},
			circleId: {
				type: Number || String,
				default: 0
			}
		},
		computed: configMap({is_community_video_start: 0}, mapGetters(['isLogin', 'viewColor', 'keyColor'])),
		methods: {
			closePublishPopup() {
				this.$emit('closePublishPopup')
			},
			addCommunityButton(type) {
				if(!this.isLogin) return this.$util.Tips({title: '请先登录，才可以发布'},{tab:1, url:'/pages/user/index'})
				let that = this
				let url = '/pages/plantGrass/plant_release/index?type='+type+'&circle_id='+that.circleId;
				if(type ==1) {
					userPerm({type:1}).then(res=>{
						if(!res.data.is_perm) {
							return uni.showModal({
								title: '温馨提示',
								content: '每个用户每月只限免费发布3次，想要发布更多请选择开通VIP？',
								success: function (res) {
									if (res.confirm) {
										return that.$util.Tips('/pages/annex/vip_paid/index');
									} else if (res.cancel) {
										console.log('用户点击取消');
									}
								}
							});
						}else{
							that.$util.Tips(url)
						}
					}).catch(err=>{
						that.$util.Tips({title: err});
					})
				} else if(type == 4) {
					that.$util.Tips('/pages/extends/user_service/index')
				} else if(type == 5) {
					that.$util.Tips('/pages/extends/user_product/create_user_product')
				} else if(type == 6) {
					/* userHasReward({type: 'is_svip'}).then(res=>{
						if(res.data.status == 1) { */
							that.$util.Tips('/pages/extends/circle_create/index')
						/* } else {
							that.user_vip_tips = true;
						}
					}) */
				} else {
					that.$util.Tips(url)
				}
				that.$emit('closePublishPopup')
				
			},
			goUrl(url) {
				let that = this;
				that.$util.Tips(url)
			},
		}
	}
</script>

<style  scoped lang='scss'>
	.publish_ceng {
		position: fixed;
		left: 0;
		top: 0;
		width: 100%;
		height: 100%;
		background: rgba(0,0,0,0.5);
		z-index: 31;
	}
	.select_checked {
		position: fixed;
		left: 0;
		bottom: 0;
		background-color: #fff;
		z-index: 32;
		width: 100%;
		text-align: center;
		padding: 20rpx 30rpx 60rpx;
		border-radius: 30rpx 30rpx 0 0;
		.selected_checket_title {
			font-size: 36rpx;
			font-weight: bold;
		}
		.selected_checket_item {
			margin-top: 30rpx;
			display: flex!important;
			flex-direction: row;
			justify-content: space-around;
			.item {
				display: block!important;
				flex-direction: unset!important;
			}
			.item-img {
				width: 120rpx;
				height: 120rpx;
				display: block!important;
				image {
					width: 120rpx;
					height: 120rpx;
				}
			}
			.item-tit {
				display: block!important;
			}
		}
	}
	.publish_button {
		/* background: #fff; */
		position: fixed;
		left: 100rpx;
		right: 100rpx;
		bottom: 128rpx;
		z-index: 31;
		.publish_btn {
			background-color: #FFE103;
			padding: 30rpx 0;
			text-align: center;
			font-size: 36rpx;
			font-weight: 500;
			color: #2C2C2C;
			line-height: 50rpx;
			margin-top: 30rpx;
			border-radius: 15rpx;
		}
	}
	/* 升级VIP弹窗 */
	.user_vip_back {
		position: fixed;
		left: 0;
		top: 0;
		width: 100%;
		height: 100%;
		background: rgba(0,0,0,0.5);
		z-index: 35;
	}
	.user_vip_content {
		background-color: #fff;
		position: fixed;
		top: 30%;
		left: 50rpx;
		right: 50rpx;
		border-radius: 30rpx;
		padding: 30rpx;
		text-align: center;
		z-index: 35;
		.user_vip_close {
			position: absolute;
			right: 30rpx;
			top: 50rpx;
			image {
				width: 50rpx;
				height: 50rpx;
			}
		}
		.user_vip_icon {
			margin: 0 auto;
			image {
				width: 140rpx;
				height: 130rpx;
				margin: 0 auto;
				display: block;
			}
		}
		.user_vip_tit  {
			margin-top: 20rpx;
		}
		.user_vip_messag {
			font-size: 32rpx;
			margin-top: 30rpx;
		}
		.user_vip_btn {
			font-weight: bold;
			background-color: #FDE515;
			display: inline-block;
			padding: 10rpx 50rpx;
			border-radius: 10rpx;
			margin-top: 30rpx;
			font-size: 42rpx;
		}
	}
</style>